bitkeeper revision 1.1159.32.1 (4120b0e7LRYrL1B3ICa0Qkit5txAbQ)
authortw275@labyrinth.cl.cam.ac.uk <tw275@labyrinth.cl.cam.ac.uk>
Mon, 16 Aug 2004 13:04:39 +0000 (13:04 +0000)
committertw275@labyrinth.cl.cam.ac.uk <tw275@labyrinth.cl.cam.ac.uk>
Mon, 16 Aug 2004 13:04:39 +0000 (13:04 +0000)
Added error checking, small button on domain list,
updated to be compatible with latest xend, and
some small changes to domain creation.

14 files changed:
.rootkeys
tools/python/xen/sv/CreateDomain.py
tools/python/xen/sv/DomInfo.py
tools/python/xen/sv/DomList.py
tools/python/xen/sv/HTMLBase.py
tools/python/xen/sv/Main.py
tools/python/xen/sv/NodeInfo.py
tools/python/xen/sv/util.py
tools/sv/Makefile
tools/sv/images/destroy.png [new file with mode: 0644]
tools/sv/images/small-destroy.png [new file with mode: 0644]
tools/sv/images/small-pause.png [new file with mode: 0644]
tools/sv/images/small-unpause.png [new file with mode: 0644]
tools/sv/inc/script.js

index 6c0a76071c4e98766f16efae15ac889d04ef2f72..a98b08862998cb7421fbc4c6c53d033ca83e5cea 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
 40cf2937Z8WCNOnO2FcWdubvEAF9QQ tools/python/xen/xm/shutdown.py
 40fcefb2K1xqVVT4D-p7nL2GzS4scg tools/sv/Main.rpy
 40ffbcb66Dj5F-1kCK9BcgSqCWkt1w tools/sv/Makefile
+4120b0e5L_nW-u0MWRfIdXg4ng4OjA tools/sv/images/destroy.png
 4107c921_OR9NTSv2dKFiLCXxrXoxA tools/sv/images/finish.png
 40fcefb3wXQMsl9WkgQAVtdrupm4sw tools/sv/images/left-end-highlight.jpg
 40fcefb3K6ESt5sQhD9aCQRscQIlXQ tools/sv/images/left-end-no-highlight.jpg
 40fcefb3dgsa24WLk_BJeYQHrDLuOg tools/sv/images/seperator-right-highlight.jpg
 40fcefb3FtiX4Pd2kT8wDlp8u8xRhQ tools/sv/images/seperator.jpg
 41013a82sUdUqBv8EoAUJii3gsZ-4g tools/sv/images/shutdown.png
+4120b0e5RyNoIQNMjUs4A2kshovjaQ tools/sv/images/small-destroy.png
+4120b0e6vW66wW6WvjQyFD0AZH2tng tools/sv/images/small-pause.png
+4120b0e6USof7ieyGxEvtCdTMpxaQw tools/sv/images/small-unpause.png
 4104ffca-jPHLVOrW0n0VghEXXtKxg tools/sv/images/unpause.png
 40fcefb3yMSrZvApO9ToIi-iQwnchA tools/sv/images/xen.png
 41013a83z27rKvWIxAfUBMVZ1eDCDg tools/sv/inc/script.js
index b4fd52f0e8f8860bd5fe66277d65ff0e6b6a5b8e..77237a3a47c4154e69345eb4cc5df536e1dcf430 100644 (file)
@@ -25,6 +25,7 @@ class CreatePage0( Sheet ):
         self.addControl( InputControl( 'name', 'VM Name', 'VM Name:', "[\\w|\\S]+", "You must enter a name in this field" ) )
         self.addControl( InputControl( 'memory', '64', 'Memory (Mb):', "[\\d]+", "You must enter a number in this field" ) )
         self.addControl( InputControl( 'cpu', '0', 'CPU:', "[\\d]+", "You must enter a number in this feild" ) )
+        self.addControl( InputControl( 'cpu_weight', '1', 'CPU Weight:', "[\\d]+", "You must enter a number in this feild" ) )
                         
 class CreatePage1( Sheet ):
 
@@ -83,9 +84,16 @@ class CreateFinish( Sheet ):
         
         xend_sxp = self.translate_sxp( string2sxp( self.passback ) )
         
-        dom_sxp = server.xend_domain_create( xend_sxp )
+        try:
+            dom_sxp = server.xend_domain_create( xend_sxp )
+            success = "Your domain was successfully created.\n"
+        except:
+            success = "There was an error creating your domain.\nThe configuration used is as follows:\n"
+            dom_sxp = xend_sxp
+            
+            
         
-        pt = PreTab( sxp2prettystring( dom_sxp ) )
+        pt = PreTab( success + sxp2prettystring( dom_sxp ) )
         pt.write_BODY( request )
 
         request.write( "<input type='hidden' name='passback' value=\"%s\"></p>" % self.passback )
@@ -106,6 +114,7 @@ class CreateFinish( Sheet ):
         vals.name =    get( 'name' )
         vals.memory =  get( 'memory' )
         vals.cpu =     get( 'cpu' )
+        vals.cpu_weight = get( 'cpu_weight' )
         
         vals.builder =  get( 'builder' )       
         vals.kernel =   get( 'kernel' )
@@ -121,7 +130,7 @@ class CreateFinish( Sheet ):
         
         vals.disk = vbds    
             
-        #misc crap
+        #misc
         
         vals.pci = []
         
@@ -145,4 +154,8 @@ class CreateFinish( Sheet ):
         
         vals.cmdline_ip = "%s:%s:%s:%s:%s:eth0:%s" % (ip, nfs, gate, mask, host, dhcp)
         
-        return make_config( vals )
+        try:
+            return make_config( vals )
+        except:
+            return [["Error creating domain config."]]    
+        
index 6f8ac1ab5bd15c1f00c2a8f26353f65cc19f07b6..3e4fb70b13983615b327a2df5c9c7e12ba681dc0 100755 (executable)
@@ -5,6 +5,8 @@ from xen.sv.HTMLBase import HTMLBase
 from xen.sv.util import *
 from xen.sv.GenTabbed import *
 
+DEBUG=1
+
 class DomInfo( GenTabbed ):
 
     def __init__( self, urlWriter ):
@@ -76,8 +78,11 @@ class DomSXPTab( PreTab ):
             request.write( "<p>Please Select a Domain</p>" )
             return None
 
-        domInfo = server.xend_domain( self.dom )
-        
+        try:
+            domInfo = server.xend_domain( self.dom )
+        except:
+            domInfo = [["Error getting domain details."]]
+            
         self.source = sxp2prettystring( domInfo )
         
         PreTab.write_BODY( self, request )
@@ -88,32 +93,54 @@ class DomActionTab( ActionTab ):
        actions = { "shutdown" : ( "Shutdown the Domain", "shutdown.png" ),
                    "reboot" : ( "Reboot the Domain", "reboot.png" ),
                     "pause" : ( "Pause the Domain", "pause.png" ),
-                    "unpause" : ( "Unpause the Domain", "unpause.png" ) }
+                    "unpause" : ( "Unpause the Domain", "unpause.png" ),
+                    "destroy" : ( "Destroy the Domain", "destroy.png" ) }
         ActionTab.__init__( self, actions )    
         
     def op_shutdown( self, request ):
        dom = getVar( 'dom', request )
-        if not dom is None:
-          print ">DomShutDown %s" % dom
-       #server.xend_node_shutdown()
+        if not dom is None and dom != '0':
+          if DEBUG: print ">DomShutDown %s" % dom
+           try:
+               server.xend_domain_shutdown( int( dom ), "halt" )
+           except:
+               pass
     
     def op_reboot( self, request ):
                dom = getVar( 'dom', request )
-        if not dom is None:
-           print ">DomReboot %s" % dom
-        #server.xend_node_reboot()
-        
+        if not dom is None and dom != '0':
+           if DEBUG: print ">DomReboot %s" % dom
+            try:
+               server.xend_domain_shutdown( int( dom ), "reboot" )
+            except:
+               pass
+                
     def op_pause( self, request ):
                dom = getVar( 'dom', request )
-        if not dom is None:
-           print ">DomPause %s" % dom
-            server.xend_domain_pause( int( dom ) )
-        
+        if not dom is None and dom != '0':
+           if DEBUG: print ">DomPause %s" % dom
+            try:
+                server.xend_domain_pause( int( dom ) )
+            except:
+               pass
+               
     def op_unpause( self, request ):
                dom = getVar( 'dom', request )
-        if not dom is None:
-          print ">DomUnpause %s" % dom
-           server.xend_domain_unpause( int( dom ) )
+        if not dom is None and dom != '0':
+          if DEBUG: print ">DomUnpause %s" % dom
+           try:
+               server.xend_domain_unpause( int( dom ) )
+          except:
+               pass
+               
+    def op_destroy( self, request ):
+       dom = getVar( 'dom', request )
+        if not dom is None and dom != '0':
+          if DEBUG: print ">DomDestroy %s" % dom
+           try:
+               server.xend_domain_destroy( int( dom ), "halt" )
+           except:
+               pass
         
     
     
index faed020b05506c19ed78866066a782c4ac222da6..d6e123143effc694d674b724b52a03f203d8cfc7 100755 (executable)
@@ -17,9 +17,14 @@ class DomList( HTMLBase ):
 
     def write_BODY( self, request, head=True, long=True ):
         
-        domains = map(int, server.xend_domains())
-        domains.sort()
+       domains = None
     
+       try:
+               domains = server.xend_domains()
+               domains.sort()
+       except:
+               pass
+                
         request.write( "\n<table style='border:0px solid white' cellspacing='0' cellpadding='0' border='0' width='100%'>\n" )
         
         if head:
@@ -29,28 +34,42 @@ class DomList( HTMLBase ):
         
         odd = True
         
-        for domain in domains:
-            if odd:
-                request.write( "<tr class='domainInfoOdd'>\n" )
-                odd = False
-            else:
-                request.write( "<tr class='domainInfoEven'>\n" )
-                odd = True
-            self.write_DOMAIN( request, getDomInfoHash( domain ), long )
-            request.write( "</tr>\n" )
-        
+        if not domains is None:
+            for domain in domains:
+                if odd:
+                    request.write( "<tr class='domainInfoOdd'>\n" )
+                    odd = False
+                else:
+                    request.write( "<tr class='domainInfoEven'>\n" )
+                    odd = True
+                self.write_DOMAIN( request, getDomInfoHash( domain ), long )
+                request.write( "</tr>\n" )
+        else:
+               request.write( "<tr colspan='10'><p class='small'>Error getting domain list<br/>Perhaps XenD not running?</p></tr>")
+                
         request.write( "</table>\n" )
             
     def write_DOMAIN( self, request, domInfoHash, long=True ):   
-        request.write( "<td class='domainInfo' align='center'>%(dom)-4d</td>\n" % domInfoHash )
+        request.write( "<td class='domainInfo' align='center'>%(id)s</td>\n" % domInfoHash )
 
-        url = self.urlWriter( "&mod=info&dom=%(dom)-4d" % domInfoHash )
+        url = self.urlWriter( "&mod=info&dom=%(id)s" % domInfoHash )
 
         request.write( "<td class='domainInfo' align='center'><a href='%s'>%s</a></td>\n" % ( url, domInfoHash['name'] ) )
         if long: 
             request.write( "<td class='domainInfo' align='center'>%(memory)5s</td>\n" % domInfoHash )
             request.write( "<td class='domainInfo' align='center'>%(cpu)2s</td>\n" % domInfoHash )
         request.write( "<td class='domainInfo' align='center'>%(state)5s</td>\n" % domInfoHash )
+        if domInfoHash[ 'id' ] != "0":
+            request.write( "<td class='domainInfo' align='center'>" )
+            
+            if domInfoHash[ 'state' ][ 2 ] == "-":
+                request.write( "<img src='images/small-pause.png' onclick='doOp2( \"pause\", \"%(dom)-4d\" )'>" % domInfoHash )
+            else:
+                request.write( "<img src='images/small-unpause.png' onclick='doOp2( \"unpause\", \"%(dom)-4d\" )'>" % domInfoHash )              
+            
+            request.write( "<img src='images/small-destroy.png' onclick='doOp2( \"destroy\", \"%(dom)-4d\" )'></td>" % domInfoHash)
+        else:
+            request.write( "<td>&nbsp;</td>" )
 
     def write_DOMAIN_HEAD( self, request, long=True ):
         request.write( "<td class='domainInfoHead' align='center'>Domain</td>\n" )      
@@ -59,4 +78,4 @@ class DomList( HTMLBase ):
             request.write( "<td class='domainInfoHead' align='center'>Memory / Mb</td>\n" )      
             request.write( "<td class='domainInfoHead' align='center'>CPU</td>\n" )      
         request.write( "<td class='domainInfoHead' align='center'>State</td>\n" )      
-            
+        request.write( "<td class='domainInfoHead' align='center'></td>\n" )
index 10d860e0c4fd9c04ee274b32b1dcfe34d5c5d6d3..e67784d55858caff055da9759bec978f8f8f9021 100755 (executable)
@@ -1,4 +1,5 @@
 from twisted.web.resource import Resource
+from xen.sv.util import *
 
 class HTMLBase( Resource ):
 
@@ -28,6 +29,7 @@ class HTMLBase( Resource ):
 
     def write_BOTTOM( self, request ):
         request.write('<input type="hidden" name="op" value="">')
+        request.write('<input type="hidden" name="args" value="">')
         request.write('</form>')
         request.write( "</body></html>" )
 
index bf6119c6002b6d60cc87901595f59f0f4ab87146..2362287c507c63c7522c1586a49f2e4e19705391 100755 (executable)
@@ -4,6 +4,8 @@ from xen.sv.NodeInfo import NodeInfo
 from xen.sv.DomInfo  import DomInfo
 from xen.sv.CreateDomain import CreateDomain
 
+from xen.xend.XendClient import server
+
 from xen.sv.util import getVar
 
 class Main( HTMLBase ):
@@ -20,14 +22,18 @@ class Main( HTMLBase ):
     def render_POST( self, request ):
     
        #decide what module post'd the action
+                
+       args = getVar( 'args', request )
 
         mod = getVar( 'mod', request )
                 
-        if not mod is None:
+        if not mod is None and args is None:
             module = self.modules[ mod ]
             #check module exists
             if module:
-               module( self.mainUrlWriter ).perform( request )     
+               module( self.mainUrlWriter ).perform( request )
+        else:
+            self.perform( request )     
     
         return self.render_GET( request )
 
@@ -80,3 +86,18 @@ class Main( HTMLBase ):
         
         request.write( "</table>\n" )
         
+                
+    def op_destroy( self, request ):
+       dom = getVar( 'args', request )
+        if not dom is None and dom != "0":
+            server.xend_domain_destroy( int( dom ), "halt" ) 
+                 
+    def op_pause( self, request ):
+       dom = getVar( 'args', request )
+        if not dom is None and dom != "0":
+            server.xend_domain_pause( int( dom ) )      
+    
+    def op_unpause( self, request ):
+       dom = getVar( 'args', request )
+        if not dom is None and dom != "0":
+            server.xend_domain_unpause( int( dom ) )      
\ No newline at end of file
index 948acef4b6e20f1bf124015e36c6fdec79650fa0..8afc41d491683808c034ebd0c49508a2ccc77578 100755 (executable)
@@ -20,8 +20,12 @@ class NodeInfoTab( GeneralTab ):
                         
     def __init__( self ):
          
-        nodeInfo = sxp2hash( server.xend_node() )
-    
+       nodeInfo = {}
+        try:
+            nodeInfo = sxp2hash( server.xend_node() )
+       except:
+            nodeInfo[ 'system' ] = 'Error getting node info'
+             
         dictTitles = {}
         dictTitles[ 'System' ] = 'system'
         dictTitles[ 'Hostname' ] = 'host' 
@@ -39,8 +43,11 @@ class NodeInfoTab( GeneralTab ):
 class NodeDmesgTab( PreTab ):
 
     def __init__( self ):
-        dmesg = server.xend_node_dmesg()
-        PreTab.__init__( self, dmesg[ 1 ] )
+       try:
+            dmesg = server.xend_node_dmesg()
+        except:
+            dmesg = "Error getting node information: XenD not running?"
+        PreTab.__init__( self, dmesg )
   
 class NodeActionTab( ActionTab ):
 
index b332b604823a44282b54170eef5d9e0ff37c66e9..3207b8f0cc12eab735c71691644c8388b76aab3e 100755 (executable)
@@ -5,8 +5,12 @@ from xen.xend import PrettyPrint
 import types
 
 def getDomInfoHash( domain ):
-    domInfoHash = sxp2hash( server.xend_domain( int( domain ) ) )
-    domInfoHash['dom'] = int( domain )
+    domInfoHash = {}
+    try:
+        domInfoHash = sxp2hash( server.xend_domain( domain ) )
+        domInfoHash['dom'] = domain
+    except:
+       domInfoHash['name'] = "Error getting domain details"
     return domInfoHash
 
 def sxp2hash( s ):
index c7bd3d5880995809b086fea54fd745f61db13e31..dcc298826ac5ec64cba6fcd9e8f1636e1f58e980 100755 (executable)
@@ -33,7 +33,12 @@ install:
        install -m0644 images/reboot.png $(sv_insdir)/images
        install -m0644 images/pause.png $(sv_insdir)/images
        install -m0644 images/unpause.png $(sv_insdir)/images
+       install -m0644 images/destroy.png $(sv_insdir)/images
         
+       install -m0644 images/small-destroy.png $(sv_insdir)/images        
+       install -m0644 images/small-pause.png $(sv_insdir)/images   
+       install -m0644 images/small-unpause.png $(sv_insdir)/images
+                        
        install -m0644 images/next.png $(sv_insdir)/images
        install -m0644 images/previous.png $(sv_insdir)/images        
        install -m0644 images/finish.png $(sv_insdir)/images 
diff --git a/tools/sv/images/destroy.png b/tools/sv/images/destroy.png
new file mode 100644 (file)
index 0000000..9545fc4
Binary files /dev/null and b/tools/sv/images/destroy.png differ
diff --git a/tools/sv/images/small-destroy.png b/tools/sv/images/small-destroy.png
new file mode 100644 (file)
index 0000000..f800bd7
Binary files /dev/null and b/tools/sv/images/small-destroy.png differ
diff --git a/tools/sv/images/small-pause.png b/tools/sv/images/small-pause.png
new file mode 100644 (file)
index 0000000..7bbdbfa
Binary files /dev/null and b/tools/sv/images/small-pause.png differ
diff --git a/tools/sv/images/small-unpause.png b/tools/sv/images/small-unpause.png
new file mode 100644 (file)
index 0000000..6ae5687
Binary files /dev/null and b/tools/sv/images/small-unpause.png differ
index fca5a972ab3fcbc9785444c2a14c92e5fde9e48e..47cd10399cfa75b4a78727ca021e82f523cc99a0 100755 (executable)
@@ -13,3 +13,10 @@ function doOp( op )
     document.forms[0].op.value = op
     document.forms[0].submit()
 }
+
+function doOp2( op, args )
+{
+    document.forms[0].op.value = op
+    document.forms[0].args.value = args
+    document.forms[0].submit()
+}